//
//  ST_ProfileErrorView.swift
//  btvideo
//
//  Created by mac on 2020/3/17.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwifterSwift
import SnapKit

class ST_ProfileErrorView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.backgroundColor = UIColor.init(white: 0.4, alpha: 0.4)
        
        self.addSubview(root_view)
        root_view.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.centerY.equalToSuperview().offset(-10)
            make.width.equalTo(200)
            make.height.equalTo(180)
        }
        
        root_view.cornerRadius = 20
        root_view.addSubview(center_mistake_image_view)
        center_mistake_image_view.snp.makeConstraints { (make) in
            make.width.height.equalTo(16)
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(35)
        }
        
        root_view.addSubview(center_image_view)
        center_image_view.snp.makeConstraints { (make) in
            make.width.height.equalTo(60)
            make.centerX.equalToSuperview()
            make.top.equalTo(center_mistake_image_view.snp.bottom).offset(5)
        }
        
        root_view.addSubview(center_label)
        center_label.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(center_image_view.snp.bottom).offset(13)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate lazy var root_view:UIView = {
       let control = UIView()
        control.backgroundColor = .white
        return control
    }()
    
    fileprivate lazy var center_image_view:UIImageView = {
        let control = UIImageView()
        control.contentMode = UIView.ContentMode.scaleAspectFill
        control.image = ST_ImageUtils.imageName("注册_img_模糊不清")
        return control
    }()
    
    fileprivate lazy var center_mistake_image_view:UIImageView = {
       let control = UIImageView()
        control.image = ST_ImageUtils.imageName("注册_icon_错误示范")
        return control
    }()
    fileprivate lazy var center_label:UILabel = {
        let control = UILabel()
        control.text = "头像不合适"
        control.textAlignment = .center
        control.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)
        control.textColor = Color.init(hex: 0x61666F)
        return control
    }()
    
    var errorStr = "头像不合适"{
        didSet{
            center_label.text = errorStr
        }
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        
        self.removeFromSuperview()
    }
}
